$(function () {

    var headerCss = readCookie('headerCss');
    var navCss = readCookie('navCss');
    var widgetCss = readCookie('widgetCss');

    if (headerCss != null) {
        $('header').css('backgroundColor', '#' + headerCss);
        $('#in-header').css('backgroundColor', '#' + headerCss);
    }

    if (navCss != null) {
        $('nav').css('backgroundColor', '#' + navCss);
        $('.sf-menu li li').css('backgroundColor', '#' + navCss);
        $('.sf-menu li li li').css('backgroundColor', '#' + navCss);
        $('#in-nav').css('backgroundColor', '#' + navCss);
        $('#sidebar').css('backgroundColor', '#' + navCss);
    }

    if (widgetCss != null) {
        $('.widget').css('backgroundColor', '#' + widgetCss);
        $('#in-widget').css('backgroundColor', '#' + widgetCss);
    }

    $('#colorChanger').change(function () {
        var str = $(this).val();
        var colors = str.split(',');

        $('header').css('backgroundColor', '#' + colors[0]);
        $('nav, .sf-menu li li, .sf-menu li li li').css('backgroundColor', '#' + colors[1]);
        $('.widget').css('backgroundColor', '#' + colors[2]);
        $('#in-header').css('backgroundColor', '#' + colors[0]);
        $('#in-nav').css('backgroundColor', '#' + colors[1]);
        $('#sidebar').css('backgroundColor', '#' + colors[1]);
        $('#in-widget').css('backgroundColor', '#' + colors[2]);

        //update cookies
        createCookie('headerCss', colors[0]);
        createCookie('navCss', colors[1]);
        createCookie('widgetCss', colors[2]);
    });



    //Table Odd/Even styles
    $("table:not(.simple) tr:nth-child(odd)").addClass("odd"); // Table Odd/Even
    $("table:not(.simple) tr:nth-child(even)").addClass("even"); // Table Odd/Even


    //Selectmenu
    $('.forcewidth').selectmenu({ width: 120 });
    $('select').selectmenu();

    //input titles to label
    //$(":text").labelify({ labelledClass: "inputHighlight" });

    // Menu
    $('ul.sf-menu').superfish();

    // message fadeout on click
    $('.msg').click(function () {
        $(this).fadeOut();
        return false;
    });


    $('.close').click(function () {
        $(this).parent().fadeOut();
        return false;
    });

    

    /*
    //jQuery UI Tabs
    $('.tabs').tabs();

    //Gallery pop-ins
    $('.gallery .hor-list').each(function () {
    $(this).hide();
    });

    $('.gallery li img').hover(function () {
    $(this).next('.hor-list').show();
    }, function () {
    $(this).next('.hor-list').hide();
    });

   
    //jQuery UI Slider
    $(".slider").slider();
    $(".slider-range").slider({
    range: true,
    min: 0,
    max: 500,
    values: [75, 300]
    });

    //jQuery UI Progressbar
    $(".progressbar").progressbar({
    value: 67
    });

    //jQuery UI Dialog
    $( "#dialog" ).dialog({
    modal: true
    });

    //jQuery UI Datepicker
    $(".datepicker").datepicker();

    //Datatable
    $('.dataTable').dataTable({
    "sPaginationType": "full_numbers",
    "bJQueryUI": true
    });

    

    // iOS checkbox
    $('.ioscheckbox').iphoneStyle({
    checkedLabel: 'On',
    uncheckedLabel: 'Off'
    });

    

    // wysiwyg editor
    $(".editor").cleditor({
    width: 620
    });

   

   

    // Tipsy
    $('#focus-example [title]').tipsy({ trigger: 'focus', gravity: 'w' });
    $('#north').tipsy({ gravity: 'n' });
    $('#south').tipsy({ gravity: 's' });
    $('#east').tipsy({ gravity: 'e' });
    $('#west').tipsy({ gravity: 'w' });
    $('#north-west').tipsy({ gravity: 'nw' });
    $('#north-east').tipsy({ gravity: 'ne' });
    $('#south-west').tipsy({ gravity: 'sw' });
    $('#south-east').tipsy({ gravity: 'se' });

    //ColorBox
    $("a[rel='example1']").prettyPhoto({ theme: 'dark_square',
    opacity: 0.9,
    show_title: true,
    social_tools: false
    });
    $("a[rel='example2']").colorbox({ transition: "fade" });
    $("a[rel='example3']").colorbox({ transition: "none", width: "75%", height: "75%" });
    $("a[rel='example4']").colorbox({ slideshow: true });
    $(".example5").colorbox();
    $(".example6").colorbox({ iframe: true, innerWidth: 425, innerHeight: 344 });
    $(".example7").colorbox({ width: "80%", height: "80%", iframe: true });
    $(".example8").colorbox({ width: "50%", inline: true, href: "#inline_example1" });

    $(".example9").colorbox({
    onOpen: function () { alert('onOpen: colorbox is about to open'); },
    onLoad: function () { alert('onLoad: colorbox has started to load the targeted content'); },
    onComplete: function () { alert('onComplete: colorbox has displayed the loaded content'); },
    onCleanup: function () { alert('onCleanup: colorbox has begun the close process'); },
    onClosed: function () { alert('onClosed: colorbox has completely closed'); }
    });
    //Example of preserving a JavaScript event for inline calls.
    $("#click").click(function () {
    $('#click').css({ "background-color": "#f00", "color": "#fff", "cursor": "inherit" }).text("Open this window again and this message will still be here.");
    return false;
    });
    */

});
